#include "ST_HELP.h"
#include "Game/Game.h"
#include "Game/SoundPlayer.h"
#include "Game/SoundDef.h"
#include "SimpleAudioEngine.h"
namespace LTGame
{
	ST_HELP::ST_HELP(GST_FLAG flag)
		: GameState(flag)
	{
		img_help = CCSprite::spriteWithFile("gui_pic/bangzhu1.jpg");
		img_help->setPosition(ccp(S_WIDTH_HALF, S_HEIGHT_HALF));
		img_help->retain();
		pageIndex = 0;
	}
	ST_HELP::~ST_HELP()
	{
		CC_SAFE_DELETE(img_help);

	}
	bool ST_HELP::logic(void)
	{
		img_help->visit();
		return true;
	}
	void ST_HELP::paint(void)
	{

	}
	bool ST_HELP::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
	{
		return true;
	}
	void ST_HELP::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
	{
		CCPoint point = pTouch->locationInView( pTouch->view() );
// 		if (CCGame->m_uiData->isPointerInBlock(point.x,point.y,Form_SelPlane,B_Form_Block_3))
// 		{
// 			if (CCGame->isOpenMusic)
// 				SOUND_PLAY_EFF(SND_CANCEL);
// 			CCGame->SetState(CCGame->getPreStateFlag());
// 		}
		if (CCGame->m_uiData->isPointerInBlock(point.x,point.y,Form_SelPlane,B_Form_Block_1))
		{
			if (CCGame->isOpenMusic)
				SOUND_PLAY_EFF(SND_OK);
			switch(pageIndex)
			{
			case 0:
				{	
					img_help = CCSprite::spriteWithFile("gui_pic/bangzhu2.jpg");
					img_help->setPosition(ccp(S_WIDTH_HALF, S_HEIGHT_HALF));
					img_help->retain();
					pageIndex = 1;
				}
				break;
			case 1:
				{
					CCGame->SetState(CCGame->getPreStateFlag());
				}
				break;
			}	
		}
	}
}